import collections
class Solution(object):
    def anagramMappings(self, nums1, nums2):
        """
        :type nums1: List[int]
        :type nums2: List[int]
        :rtype: List[int]
        """
        d = collections.defaultdict(set)
        for i in range(len(nums2)):
            d[nums2[i]].add(i)
        for i in range(len(nums1)):
            nums1[i] = d[nums1[i]].pop()
        return nums1